package student

import (
	"fmt"
	"time"
)

type toufa struct {
	yanse   string
	changdu string
}

type head struct {
	toufa toufa
	zuiba string
}
type Shou struct {
}
type Jiao struct {
	changdu    float32
	kuandu     float32
	zhongliang float32
}

type people struct {
	naodai     head
	zuoshou    Shou
	youshou    Shou
	zuojiao    Jiao
	youjiao    Jiao
	Name       string
	sn         string
	Age        int
	height     float32
	address    string
	xuedli     string
	level      int
	fathername string
	money      float32
	fuqin      *people

	muqin *people
}
type class struct {
	name     string
	nianji   string
	banzhang people

	xuexiweiyuan people

	xuesheng []people
}
type zhuanye struct {
	xizhuren people

	liebiao []class
}
type xueyuan struct {
	yuanzhang people

	zhuanyeLiebiao []zhuanye
}

type xuexiao struct {
	xiaozhang people

	xueyuanliebiao []xueyuan
}

type country struct {
	name  string
	zhuxi people
}

type Student struct {
	people

	xuehao  string
	chengji float32
	teacher *people
}
type YunStudent struct {
	Student
	yunIP    string
	yunZhuji string
	yunFudao *people
}

func (s *Student) study() {

	fmt.Println(s.Name, "在学习")
}

func (p *people) qunfaHongbao(edu float32, jieshouList ...*people) {
	singleEdu := edu / float32(len(jieshouList))
	for i := 0; i < len(jieshouList); i++ {
		item := jieshouList[i]
		p.fahongbao(item, singleEdu)
	}
}

func (p *people) fahongbao(to *people, edu float32) bool {
	if p.money < edu {
		fmt.Println(p.Name, "已经没有钱发红包了")
		return false
	}
	p.money = p.money - edu
	to.money = to.money + edu

	return true
}

func HongbaoDemo() {
	var zhangsan people

	zhangsan.Name = "张三"
	zhangsan.money = 100
	var myhead head

	zhangsan.naodai = myhead

	fmt.Println(zhangsan.Name, "父亲是:", zhangsan.fuqin)

	var lisi people

	lisi.Name = "李四"
	lisi.money = 100

	var lingyigeHead head

	lisi.naodai = lingyigeHead
	lisi.fuqin = &zhangsan

	fmt.Println(lisi.Name, "的父亲是", lisi.fuqin)
	return
	var wangwu people

	wangwu.Name = "王五"
	wangwu.money = 100
	var chenliu people

	chenliu.Name = "陈留"
	chenliu.money = 100
	chenliu.fuqin = &zhangsan
	chenliu.muqin = &wangwu

	var moumou Student
	moumou.Name = "某某"
	moumou.Age = 19
	moumou.xuehao = "20220404101"

	var cuihui Student
	cuihui.Name = "崔慧"
	cuihui.xuehao = "3245643"
	cuihui.study()
	var syj YunStudent
	syj.Name = "孙玉洁"
	syj.Age = 19
	syj.yunIP = "172.14.0.21"
	syj.yunZhuji = "www.sadfsaddsf.com"
	syj.study()
	syj.yunFudao = &zhangsan
	syj.teacher = &lisi

	cuihui.fahongbao(&moumou.people, 22)

	for {
		var edu float32
		fmt.Println("请输入红包的额度")
		fmt.Scanln(&edu)
		fmt.Println("发红包之前")
		fmt.Println(zhangsan.Name, zhangsan.money)
		fmt.Println(lisi.Name, lisi.money)
		fmt.Println(wangwu.Name, wangwu.money)
		fmt.Println(chenliu.Name, chenliu.money)
		fmt.Println(chenliu.fuqin.fuqin)
		zhangsan.qunfaHongbao(edu, &lisi, &wangwu, &chenliu)
		fmt.Println("发红包之后")
		fmt.Println(zhangsan.Name, zhangsan.money)
		fmt.Println(lisi.Name, lisi.money)
		fmt.Println(wangwu.Name, wangwu.money)
		fmt.Println(chenliu.Name, chenliu.money)
	}
}

func (p *people) chifan() {

	for i := 0; i < 30; i++ {
		if p.Age < 2 {
			fmt.Println(p.Name, "zai 喝奶")
		} else if p.Age < 6 {
			p.level = 2
			fmt.Println(p.Name, "zai 吃粥")
		} else if p.Age > 80 {
			p.level = 20
			fmt.Println(p.Name, "zai 喝粥")
		} else {
			p.level += 1
			fmt.Println(p.Name, "在", p.address, "吃饭")
		}
		time.Sleep(time.Second * 2)

		fmt.Println("当前是", p.level)
		p.Age += 5

	}
}
func (p *people) shuijiao() {
	fmt.Println(p.Name, "在睡觉")
}
